function loadOrderList() {
	var id = $("#useridoflogin").val();
//	var id = '4d272484d5844be693c05443c4edd71e'
	var sele = $("#timeOption option:selected").val();

	$.ajax({
		url : Server + "/front/info/order",
		//url : "http://localhost/front/info/order",
		type : "POST",
		dataType : "json",
		data:{
			"id" : id,
			"sele": sele
		},
		success : function(data) {
			//<img src="images/usercenter_icon2.png" onclick="deleOrder(#9)" />
			var html = "";
			var pattern = '<li>\
				<div class="row1">\
					<div>\
						<span>#0 </span>\
						<span>订单编号: #1</span>\
					</div>\
					<div></div>\
				</div>\
				<div class="row2">\
					<div class="tab1"><img src="#2" /></div>\
					<div class="tab2">#3</div>\
					<div class="tab3">#4</div>\
					<div class="tab4">#5</div>\
					<div class="tab5">\
						<p>#6</p>\
						<p>\
							<a onclick="findOrder(#7)">查看详情</a>\
						</p>\
					</div>\
					<div class="tab6">\
						<div class="btn">\
							<a onclick="manageDo(#11)">#8</a>\
						</div>\
						<div class="time">还剩11:23:02</div>\
					</div>\
				</div>\
			</li>';

			for(var i = 0; i < data.length; i++){
				var item = "";
				var order = data[i];
				var Status = "";
				var Status1 = "";
				switch (data[i].status)//0:待确认 1:待支付 2:待试验 3:已完成 4:已评价
				{
					case 0:
						Status = "待确定";
						Status1 = "确定";
						break;
					case 1:
						Status = "待支付";
						Status1 = "";
						break;
					case 2:
						Status = "已支付";
						Status1 = "";
						break;
					case 3:
						Status = "待确定";
						Status1 = "确定";
						break;
					case 4:
						Status = "待试验";
						Status1 = "";
						break;
					case 5:
						Status = "已完成";
						Status1 = "评价";
						break;
					case 6:
						Status = "已评价";
						Status1 = "";
						break;
					case 7:
						Status = "已关闭";
						Status1 = "";
						break;
				}
				item += pattern.replace("#0", data[i].createTime)
					.replace("#1", data[i].number)
					//.pattern.replace("#2", data[i].insInfo.infoSrc)
					.replace("#3", data[i].insInfo.chineseName)
					.replace("#4", data[i].insInfo.serial)
					.replace("#5", data[i].realname)
					.replace("#6", Status)
					.replace("#7", data[i].id)
					.replace("#8", Status1)
					.replace("#9", data[i].id)
					.replace("#11", data[i].id);
				html += item;
			}
			$("#orderList").html(html);
		}
	});
}

function findOrder(id){
	$(location).attr('href', 'bookingOrderDetail24?id='+id+'&type=1');
}

function manageDo(id){
	$(location).attr('href', 'bookingOrderDetail24?id='+id+'&type=2');
}


function particulars(id,type){
	$.ajax({
		url : Server + "/front/info/findOrder",
		//url : "http://localhost/front/info/findOrder",
		type : "POST",
		data: {
			"id" : id
		},
		success : function(data) {
			var order = data;
			/*仪器信息*/
			$("form input[name = 'orderId']").val(order.id);
			$("form input[name = 'infoNumber']").val(order.insInfo.number);
			$("form input[name = 'chineseName']").val(order.insInfo.chineseName);
			$("form input[name = 'unitName']").val(order.control.unitName);
			$("form input[name = 'address']").val(order.insInfo.address);
			$("form input[name = 'realname']").val(order.control.realname);
			$("form input[name = 'phone']").val(order.control.phone);
			$("form input[name = 'email']").val(order.control.email);
			/*申请人信息*/
			$("form input[name = 'sonRealname']").val(order.consum.realname);
			$("form input[name = 'mobile']").val(order.consum.mobile);
			$("form input[name = 'consumUnitName']").val(order.consum.unitName);
			$("form input[name = 'createTime1']").val(order.createTime);
			/*预约申请信息*/
			var use = '';
			var way = '';
			var fundingCode = '';
			var fundingSource = '';
			var prinpical = '';
			if(order.orderappli != null){
				use = (order.orderappli.use == '')?'':order.orderappli.use;
				way = (order.orderappli.way == '')?'':order.orderappli.way;
				fundingCode = (order.orderappli.fundingCode == '')?'':order.orderappli.fundingCode;
				fundingSource = (order.orderappli.fundingSource == '')?'':order.orderappli.fundingSource;
				prinpical = (order.orderappli.prinpical == '')?'':order.orderappli.prinpical;
			}
			$("form input[name = 'orderNumber']").val(order.number);
			$("form input[name = 'use']").val(use);
			$("form input[name = 'way']").val(way);
			$("form input[name = 'fundingCode']").val(fundingCode);
			$("form input[name = 'createTime2']").val(order.createTime);
			$("form input[name = 'projectName']").val(order.createTime);
			$("form input[name = 'fundingSource']").val(fundingSource);
			$("form input[name = 'prinpical']").val(prinpical);
			/*待测样品信息信息表格*/
			var Sample = data.sample;
			var pattern = '<div class="box_title">待测样品信息信息</div><ul><li><label>待测试内容</label>\
				<table><tr><th>序号</th><th>测试内容</th><th>数量</th><th>预算费用</th><th>样品描述与测试要求</th>\
			</tr>';
			for(var i = 0; i < Sample.length; i++){
				pattern += "<tr><td>"+Sample[i].id+"</td><td>"+Sample[i].centent+"</td><td>"+Sample[i].count+"</td><td>"+Sample[i].fee+"</td><td>"+Sample[i].desc+"</td></tr>";
			}
			pattern += '</table></li></ul>';
			$(".Sample").html(pattern);
			if(type == 1){
				$('#OK').remove();
			}
			/*if(order.status != 0){
				$("#OK").remove();
			}*/
		},
		error : function(msg) {}
	});
}



function upStatus(id,status){
	var r=confirm("是否确认？");
	if(r==true){
		changeStatus(id,status);
	}
}
function changeStatus(id,status){
	$.ajax({
		url :Server + "/orderRelevant/changeStatus",
		//url :"http://localhost/orderRelevant/changeStatus",
		data : {
			"id":id,
			"status":status
		},
		type : "POST",
		//dataType: "JSON",
		success : function(data) {
			alert(data)
			$(location).attr("href","book_admin23");
		},
		error : function(data) {
			alert("确认异常！")
		}
	});	
}


//function deleOrder(oid) {
//	var msg = "您真的确定要删除吗？\n\n请确认！";
//	if (confirm(msg) == true) {
//		del(oid);
//		return true;
//	} else {
//		return false;
//	}
//}
//function del(id) {
//	$.ajax({
//		url :Server + "/orderRelevant/deleteOrder",
////		url :"http://localhost/orderRelevant/deleteOrder",
//		data : {
//			"id" : id,
//		},
//		type : "POST",
//		dataType : "json",
//		success : function(data) {
//			alert("删除成功");
//			loadOrderList();
//		},
//		error : function(msg) {
//			alert("删除失败");
//			loadOrderList();
//		}
//	});
//}
